<?php

namespace model;


use model\CommonModel;

class UserInfoModel extends  CommonModel
{
    protected $table = 'user_info';


    /**
     * 根据用户id 获取被保险人的保单信息
     * @param $user_id
     * @return false|\PDOStatement|string|\think\Collection
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function getPolicyByUserId($user_id)
    {
        $join = [
            ['policy p','p.remer_id = user_info.ui_id','LEFT']
        ];
        $where = [
            'user_info.ui_id'=>$user_id
        ];
        $info =  $this->join($join)->where($where)->field('p.created_at,p.policy_num,p.policy_status,p.p_id')->select();
        return collection($info);
    }





}